package arm.dic.bean;

import arm.dic.entity.DicPost;
import arm.common.manager.TableManager;
import arm.db.tools.DBManager;

public class DicPostBean
{
    private DicPost post;
    private TableManager<DicPost> tableManager;

    public DicPost getPost() {
        return post;
    }

    public void setPost(DicPost post) {
        this.post = post;
    }

    public String create()
    {
        post = new DicPost();
        return "editDicPost";
    }


    public String save()
    {
        DBManager.saveOrUpdate(getPost());
        return viewTable();
    }

    public String edit()
    {
        setPost(getTableManager().getSelectedObj());
        return "editDicPost";
    }

    public String cancel()
    {
        return viewTable();
    }

    public String viewTable ()
    {
        getTableManager().readFromDB();
        return "viewDicPostTable" ;
    }

    public TableManager<DicPost> getTableManager() {
        if (tableManager == null)
        {
            tableManager = new TableManager<DicPost>(DicPost.class);
        }
        return tableManager;
    }

    public void setTableManager(TableManager<DicPost> tableManager) {
        this.tableManager = tableManager;
    }

    public void delete ()
    {
        DBManager.delete(getTableManager().getSelectedObj());
        getTableManager().readFromDB();
    }


}


